home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 8: LINUX Games / Linux Cubed Series 8 - LINUX Games.iso / games / muds / mordor_2.000 / mordor_2 / src / dm6.c < prev    next >
C/C++ Source or Header  |  1995-06-21  |  8KB  |  294 lines

  1. /*
  2.  * DM6.C:
  3.  *
  4.  *  DM functions
  5.  *
  6.  *  Copyright (C) 1991, 1992, 1993 Brett J. Vickers
  7.  *  Copyright (C) 1995 Brooke Paul
  8.  *
  9.  */
  10.  
  11. #include "mstruct.h"
  12. #include "mextern.h"
  13.  
  14. /**********************************************************************/
  15. /*                dm_dust                      */
  16. /**********************************************************************/
  17.  
  18. /* This function allows a DM to destory a player.              */
  19.  
  20. int dm_dust(ply_ptr, cmnd)
  21. creature        *ply_ptr;
  22. cmd             *cmnd;
  23. {
  24.         creature        *crt_ptr;
  25.         int             cfd, fd;
  26.         char            str[IBUFSIZE+1]; 
  27.     char        file[80];
  28.  
  29.         if(ply_ptr->class < DM)
  30.                 return(PROMPT);
  31.  
  32.     if(cmnd->num < 2) {
  33.         print(ply_ptr->fd, "\nDust whom?\n");
  34.         return(PROMPT);
  35.     }
  36.         lowercize(cmnd->str[1], 1);
  37.         crt_ptr = find_who(cmnd->str[1]);
  38.         if(!crt_ptr) {
  39.                 print(ply_ptr->fd, "%s is not on.\n", cmnd->str[1]);
  40.                 return(0);
  41.     }
  42.     if(crt_ptr->class > CARETAKER) {
  43.         ANSI(crt_ptr->fd, RED);
  44.         print(crt_ptr->fd, "%s tried to dust you!\n", ply_ptr->name);
  45.         ANSI(crt_ptr->fd, WHITE);
  46.         return(0);
  47.     }
  48.     cfd = crt_ptr->fd;
  49.     if(!(Ply[cfd].io->fn == command && Ply[cfd].io->fnparam == 1)) {
  50.         print(ply_ptr->fd, "Can't dust %s right now.\n", cmnd->str[1]);
  51.         return(0);
  52.     }
  53.     ANSI(cfd, MAGENTA);
  54.     print(cfd, "Lightning comes down from on high!  You have angered the gods!\n");
  55.     ANSI(cfd, WHITE);
  56.     broadcast_rom(cfd, crt_ptr->rom_num,"A bolt of lightning strikes %s from on high.\n",crt_ptr->name);
  57.     broadcast("\n### %s has been turned to dust! We'll miss %s dearly.", Ply[cfd].ply->name, F_ISSET(Ply[cfd].ply, PMALES) ? "him":"her");
  58.                 sprintf(file, "%s/%s", PLAYERPATH, Ply[cfd].ply->name);
  59.                 disconnect(cfd);
  60.         broadcast("### Ominous thunder rumbles in the distance.\n");
  61.             unlink(file);
  62.                 return(0);
  63.  
  64. }
  65.  
  66. /**********************************************************************/
  67. /*                              dm_follow                             */
  68. /**********************************************************************/
  69. /*    This function allows a DM to force a monster to follow           */
  70. /*    him, and has been made to allow for the movement of          */
  71. /*      custom monsters (made with the dm_crt_name function).          */
  72.  
  73. int dm_follow (ply_ptr, cmnd)
  74. creature        *ply_ptr;
  75. cmd             *cmnd;
  76. {
  77.     creature    *crt_ptr;
  78.     room        *rom_ptr;
  79.     ctag        *pp, *cp, *prev;
  80.     int        fd;
  81.  
  82.     fd = ply_ptr->fd;
  83.     rom_ptr = ply_ptr->parent_rom;
  84.  
  85.     if(ply_ptr->class < CARETAKER)
  86.                 return(PROMPT);    
  87.  
  88.     if (cmnd->num < 2) {
  89.         print (fd, "syntax: *cfollow <creature>\n");
  90.         return(0);
  91.     }
  92.  
  93.         crt_ptr = find_crt(ply_ptr, rom_ptr->first_mon, cmnd->str[1],
  94.                            cmnd->val[1]);
  95.  
  96.     if(!crt_ptr) {
  97.         print (fd, "Can't seem to locate that creature here.\n");
  98.         return (0);
  99.     }
  100.  
  101.     if(F_ISSET(crt_ptr, MPERMT)) {
  102.         print (fd, "Perms can't follow.\n");
  103.         return(0);
  104.     }
  105.     if(F_ISSET (crt_ptr, MDMFOL)) {
  106.         F_CLR(crt_ptr, MDMFOL);
  107.         print (fd, "%s stops following you.\n", crt_ptr->name);
  108.         cp = ply_ptr->first_fol;
  109.         if(cp->crt == crt_ptr) {
  110.             ply_ptr->first_fol = cp->next_tag;
  111.             free(cp);
  112.         }
  113.         else while (cp) {
  114.             if (cp->crt == crt_ptr) {
  115.                 prev->next_tag = cp->next_tag;
  116.                 free(cp);
  117.                 break;
  118.             }
  119.              prev = cp;
  120.              cp = cp->next_tag;
  121.              }
  122.  
  123.         crt_ptr->following = 0;
  124.         return(0);
  125.     }
  126.     crt_ptr->following = ply_ptr;
  127.     F_SET(crt_ptr, MDMFOL);
  128.     pp = (ctag *)malloc(sizeof(ctag));
  129.     if(!pp)
  130.         merror("dmfollow", FATAL);
  131.     pp->crt = crt_ptr;
  132.     pp->next_tag = 0;
  133.     
  134.     if(!ply_ptr->first_fol)
  135.         ply_ptr->first_fol = pp;
  136.     else {
  137.         pp->next_tag = ply_ptr->first_fol;
  138.         ply_ptr->first_fol = pp;
  139.     }    
  140.     print (fd, "%s starts following you.\n", crt_ptr->name);
  141.     return (0);
  142. }
  143.  
  144. /************************************************************************/
  145. /*            dm_attack                    */
  146. /************************************************************************/
  147. /*     This function allows a DM to make a monster attack a given     */
  148. /*  player.                                */
  149.  
  150. int dm_attack (ply_ptr, cmnd)
  151. creature        *ply_ptr;
  152. cmd             *cmnd;
  153. {
  154.     creature    *atr_ptr, *atd_ptr;
  155.     room        *rom_ptr;
  156.     ctag        *pp, *cp, *prev;
  157.     int        fd;
  158.  
  159.     fd = ply_ptr->fd;
  160.     rom_ptr = ply_ptr->parent_rom;
  161.  
  162.     if(ply_ptr->class < CARETAKER)
  163.                 return(PROMPT);    
  164.  
  165.     if (cmnd->num < 3) {
  166.         print (fd, "syntax: *attack <monster> <defender>\n");
  167.         return(0);
  168.     }
  169.  
  170.         atr_ptr = find_crt(ply_ptr, rom_ptr->first_mon, cmnd->str[1],
  171.                            cmnd->val[1]);
  172.  
  173.     if(!atr_ptr) {
  174.         print (fd, "Can't seem to locate that attacker here.\n");
  175.         return (0);
  176.     }
  177.  
  178.     if(F_ISSET(atr_ptr, MPERMT)) {
  179.         print (fd, "Perms can't do that.\n");
  180.         return(0);
  181.     }
  182.  
  183.         atd_ptr = find_crt(ply_ptr, rom_ptr->first_mon, cmnd->str[2],
  184.                            cmnd->val[2]);
  185.  
  186.     if(!atd_ptr) {
  187.     lowercize(cmnd->str[2], 1);
  188.     atd_ptr = find_who(cmnd->str[2]);
  189.     }
  190.  
  191.     if(!atd_ptr) {
  192.         print (fd, "Can't seem to locate that victim here.\n");
  193.         return (0);
  194.     }
  195.  
  196.     if(F_ISSET(atd_ptr, MPERMT)) {
  197.         print (fd, "Perms can't do that.\n");
  198.         return(0);
  199.     }
  200.     print(fd, "Adding %s to attack list of %s.\n", atd_ptr->name, atr_ptr->name);
  201.     add_enm_crt(atd_ptr->name, atr_ptr);
  202.     broadcast_rom(atd_ptr->fd, atd_ptr->rom_num, "%M attacks %m.", atr_ptr, atd_ptr);
  203.     if(atd_ptr->type = PLAYER) 
  204.         print (atd_ptr->fd, "%M attacked you!\n", atr_ptr);
  205.     return(0);
  206. }
  207.  
  208. /***************************************************************************/
  209. /*            list_enm                       */ 
  210. /***************************************************************************/
  211. /*    This function lists the enemy list of a given monster.           */
  212.  
  213. int list_enm(ply_ptr, cmnd)
  214. creature *ply_ptr;
  215. cmd     *cmnd;
  216.  
  217. {
  218. etag    *first_enm;
  219. etag    *ep;
  220. room    *rom_ptr;
  221. creature *crt_ptr;
  222. int    fd, n=0;
  223.  
  224.     if (ply_ptr->class < DM)
  225.             return(0);
  226.     
  227.     rom_ptr= ply_ptr->parent_rom;
  228.     fd = ply_ptr->fd;
  229.  
  230.     crt_ptr = find_crt(ply_ptr, rom_ptr->first_mon, cmnd->str[1], cmnd->val[1]);
  231.  
  232.     if(!crt_ptr){
  233.         print(fd, "Not here.\n");
  234.         return(0);
  235.     }
  236.     print(ply_ptr->fd,"Enemy list for %s:\n", crt_ptr->name);
  237.  
  238.         ep = crt_ptr->first_enm;
  239.  
  240.     while(ep) {
  241.     n +=1;
  242.     print (fd,"%s.\n", ep->enemy);
  243.         ep = ep->next_tag;
  244.     }
  245.     if (!n)
  246.     print(fd, "None.\n");
  247.     return(0);
  248. }
  249.  
  250. /**********************************************************************/
  251. /*                              list_charm                            */
  252. /**********************************************************************/
  253. /*      This function allows a DM to see a given players charm list   */
  254.                 
  255. int list_charm (ply_ptr, cmnd)
  256. creature        *ply_ptr;
  257. cmd             *cmnd;
  258. {
  259.                         
  260. creature        *crt_ptr;
  261. int             fd, cfd, n=0;
  262. ctag            *cp;
  263.                                 
  264.         if(ply_ptr->class < DM)
  265.                 return(PROMPT);
  266.                          
  267.         if(cmnd->num < 2) {
  268.                 print(ply_ptr->fd, "See whose charm list?\n");
  269.                 return(PROMPT);
  270.         }
  271.                 
  272.         fd = ply_ptr->fd; 
  273.         lowercize(cmnd->str[1], 1);
  274.         crt_ptr = find_who(cmnd->str[1]);
  275.         if(!crt_ptr) {
  276.                 print(ply_ptr->fd, "%s is not on.\n", cmnd->str[1]);
  277.                 return(0);
  278.         }
  279.         
  280.         cfd = crt_ptr->fd;
  281.          
  282.         cp = Ply[cfd].extr->first_charm;
  283.         print (fd, "Charm list for %s:\n", crt_ptr->name);
  284.         while(cp) {
  285.         n += 1;
  286.                 print(fd,"%s.\n", cp->crt->name); 
  287.                 cp = cp->next_tag;
  288.         }
  289.         if(!n)
  290.         print(fd, "Nobody.\n");
  291.     return(0);
  292. }
  293.  
  294.